<template>
  <div class="child">
    <h2>我是Child组件</h2>
    <input type="text" :value="str" @input="handleInput">
    <br>
    性别：
      男<input type="radio" name="sex" :checked="gender === 'male' " @click="handleGenderInput('male')">
      女<input type="radio" name="sex" :checked="gender === 'female' " @click="handleGenderInput('female')">
  </div>
</template>

<script>
  export default {
    name:'Child',
    props:['str','updateStr','gender','updateGender'],
    methods: {
      // 第一个输入框的回调
      handleInput(event){
        console.log(event.target.value)
        this.updateStr(event.target.value)
      },
      // 性别单选按钮输入的回调
      handleGenderInput(value){
        // console.log(event.target.value)
        this.updateGender(value)
      }
    },
  }
</script>

<style scoped>
  .child {
    background-color: skyblue;
    padding: 10px;
  }
</style>